package Lambda;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;

/**
 * @Author: Miyako
 * @Date: 2024-07-15-14:42
 * @Description:λ(Lambda)表达式
 */
public class LambadaDemo01 {
    public static void main(String[] args) {
        Random rand = new Random();
        List<Integer> intList = new ArrayList<>();

        while(intList.size()<10){
            Integer r= rand.nextInt(101);
            intList.add(r);
        }
        intList.sort((o1, o2) -> o2 - o1);
        System.out.println(intList);
        int i =0;
        for (Integer x : intList){
            i++;
            if (i==5) {
                System.out.println(x);
                break;
            }
        }
        intList.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.print(integer+" ");
            }
        });

        System.out.println();

        intList.forEach(n-> System.out.print(n+" "));//上下等价
    }
}
